// 请求基地址
import BASE_URL from "./env";
export const request = (options) => {
	return new Promise((resolve, reject) => {
		// 获取用户令牌

		// let token = useUserStore().token
		const token = ""

		uni.request({
			url: BASE_URL + options.url,
			method: options.method || 'GET', //接收请求的方式,如果不传默认为GET
			data: options.data || {}, //接收请求的data,不传默认为空
			header: {
				Accept: "application/json, text/plain, */*",
				"Content-Type": "application/json",
				// "X-Requested-With": "XMLHttpRequest"
			},
			timeout: 5000,
			success: (res) => {
				console.log('请求接口', res)
				if (res.statusCode == 200) {
					resolve(res.data)
				}
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}